package org.example;

import java.util.HashSet;
import java.util.Set;

/**
 * @Title : HshCode
 * @Description: :
 * @author: libo@juzishuke.com
 * @date: 2023/10/13 14:49
 * @Version:1.0
 */
public class HshCode {

    public static void main(String[] args) {
        StringBuilder mpid = new StringBuilder();
        mpid.append("23");
        Set<Long> workIds = new HashSet<>();
        int count = 0;
        for (long pid = 1; pid <= 4194304; pid++) {
            mpid = new StringBuilder();
            mpid.append("23");
            mpid.append(pid);
            long workerId = (mpid.toString().hashCode() & 0xffff) % (31 + 1);
            if (workIds.contains(workerId)) {
                System.out.println("冲突workerId " + workerId + " , pid = " + pid);
                count++;
            }else{
                workIds.add(workerId);
            }
        }
        System.out.println(workIds.size());
    }

}
